import faker from 'faker'
import {Response, Request} from 'express'
import {ITransactionData} from '../src/api/types'

const transactionList: ITransactionData[] = []
const transactionCount = 20

for (let i = 0; i < transactionCount; i++) {
  transactionList.push({
    orderId: faker.random.uuid(),
    status: faker.random.arrayElement(['success', 'pending']),
    timestamp: faker.date.past().getTime(),
    username: faker.name.findName(),
    price: parseFloat(faker.finance.amount(1000, 15000, 2))
  })
}

export const getTransactions = (req: Request, res: Response) => {
  debugger
  return new Promise((resolve, reject) => {
    resolve({
      "code": 20000, "data": {
        "total": 20,
        "items": [{
          "orderId": "1d4e79e8-9f4b-48cc-a730-499d480c311c",
          "status": "success",
          "timestamp": 1604898223729,
          "username": "Adan Mertz",
          "price": 2626.3
        }, {
          "orderId": "65c809fb-067c-4fdd-8863-235b1a130661",
          "status": "success",
          "timestamp": 1593522729192,
          "username": "Mrs. Danika Fay",
          "price": 14527.23
        }, {
          "orderId": "e5bf30b1-0437-48ef-911d-dfedd2543ef3",
          "status": "success",
          "timestamp": 1590444561264,
          "username": "Eulah Wunsch MD",
          "price": 14330.94
        }, {
          "orderId": "e3fbae00-25c3-4d2b-b3dc-45d90c81ceae",
          "status": "pending",
          "timestamp": 1583497297205,
          "username": "Dana Prohaska",
          "price": 14686.32
        }, {
          "orderId": "003e98e8-7902-4e0a-8079-22187f3890d0",
          "status": "pending",
          "timestamp": 1594244734925,
          "username": "Bridget Hand",
          "price": 12353.9
        }, {
          "orderId": "1249e6a2-4dac-4a1d-b7c2-6c33fdb65dcf",
          "status": "pending",
          "timestamp": 1603244822414,
          "username": "Bridgette Hegmann",
          "price": 13503.84
        }, {
          "orderId": "b72a85ec-208b-4c4e-9c17-1bea1d500222",
          "status": "pending",
          "timestamp": 1598995551583,
          "username": "Veronica Trantow",
          "price": 14824.99
        }, {
          "orderId": "cdf464c9-bf38-4859-b12f-f85c75721f30",
          "status": "success",
          "timestamp": 1583397988795,
          "username": "Ada O'Connell",
          "price": 11605.45
        }, {
          "orderId": "9c38364f-b99b-4e1f-820d-ea73f40b5ddf",
          "status": "pending",
          "timestamp": 1606749643461,
          "username": "Russel Gislason",
          "price": 4039.07
        }, {
          "orderId": "7d3fb05f-2b57-4f5a-a08d-8600087b8844",
          "status": "pending",
          "timestamp": 1590867749207,
          "username": "Clifford Schaefer",
          "price": 5440.6
        }, {
          "orderId": "e6752c77-8997-42b8-b8de-e90fcb5878c5",
          "status": "pending",
          "timestamp": 1609848531095,
          "username": "Macey Auer",
          "price": 14018.47
        }, {
          "orderId": "72bed67b-6bd9-4948-950e-18859038b28f",
          "status": "pending",
          "timestamp": 1606818025526,
          "username": "Alden Metz",
          "price": 5211.75
        }, {
          "orderId": "7b5e09bc-7916-4b65-9381-309b4957dfb1",
          "status": "pending",
          "timestamp": 1594877890194,
          "username": "Lilyan Baumbach",
          "price": 4589.54
        }, {
          "orderId": "d1aa3309-a32a-4749-8c1b-0f801a285991",
          "status": "pending",
          "timestamp": 1589165408341,
          "username": "Abbigail Kreiger",
          "price": 14513.37
        }, {
          "orderId": "ee4d6daa-a32e-44c0-9451-94cb2db7b197",
          "status": "pending",
          "timestamp": 1596428361586,
          "username": "Emery Friesen",
          "price": 10589.98
        }, {
          "orderId": "aceb6f6f-f4a9-42e1-a98e-85cfe73ec4ad",
          "status": "success",
          "timestamp": 1599991232882,
          "username": "Xander Feil",
          "price": 7342.31
        }, {
          "orderId": "9cddf2f1-ee25-4ec4-aa43-f68ee827038a",
          "status": "success",
          "timestamp": 1601541272752,
          "username": "Abbey Stamm",
          "price": 1220.74
        }, {
          "orderId": "128d690b-397e-4887-9979-ea3b36c2a58e",
          "status": "pending",
          "timestamp": 1599514337270,
          "username": "Norene Daniel",
          "price": 11804.41
        }, {
          "orderId": "c5e0acc3-9c6a-4cf5-8054-fdfa7c6aaa9b",
          "status": "pending",
          "timestamp": 1596598167551,
          "username": "Clyde Daniel",
          "price": 10709.72
        }, {
          "orderId": "f249dd8b-e810-4487-9f2a-fce7dfafea16",
          "status": "success",
          "timestamp": 1599144254857,
          "username": "Davonte Orn",
          "price": 9213.18
        }]
      }
    })
  })
}
// {
//   return res.json({
//     code: 20000,
//     data: {
//       total: transactionList.length,
//       items: transactionList
//     }
//   })
// }
